/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
	   \file			mainwindow.h
	   \date			Sep 2011
	   \author		TNick

	   \brief		Contains the definition for MainWindow class


	   Copyright (c) 2011, Nicu Tofan
	   All rights reserved.

	   Redistribution and use in source and binary forms, with or without
	   modification, are permitted provided that the following conditions are met:
	   * Redistributions of source code must retain the above copyright
	   notice, this list of conditions and the following disclaimer.
	   * Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.
	   * Neither the name of the copyright holder nor the
	   names of its contributors may be used to endorse or promote products
	   derived from this software without specific prior written permission.

	   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
	   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
	   DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
	   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
	   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
	   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
	   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

	   */
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __MAINWINDOW_INC__
#define __MAINWINDOW_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class       MdiChild;

#include    <QMainWindow>
#include    <QMdiSubWindow>

#include	"mw_basicslots.h"
#include	"mw_stylesheets.h"
#include	"mw_sheetslots.h"
#include	"mw_recentfiles.h"
#include	"mw_basicmdi.h"
#include	"mw_uitemplates.h"


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace Ui {
class MainWindow;
}

/// form that represents main GUI component
/**
*	This class is the one instantiated by main() function. It is divided
*	in several logical units for reusability and maintainability. These
*	logical units are classes that start with \b MW_ and are embedded in
*	this class, hawing names that start with \b c_ (for component). Each unit
*	has an \b init function that needs to be called from the constructor.
*
*	\section basic_slots Basic slots [generic]
*	The class that defines this logical unit is MW_BasicSlots. It is
*	embedded in MainWindow with MainWindow::c_bs_slot variable. Grouped here
*	are some of the event handlers that are most likely to be used by
*	any simple GUI application.
*
*	Initialization function binds actions contained in the MainWindow
*	with internal slots. The actions that are targeted include the
*	new document ones (new and open), save document (current, all, current
*	as a different file), print (actual print, set-up and preview), basic
*	editing (undo and redo, cut copy, paste, delete, select all), changes
*	in the layout direction and help (main help, about, about Qt and
*	contextual help). Also, there is a slot that listens to changes in
*	selection state (present or not) and changes the managed GUI elements
*	accordingly.
*
*	\section recent_files Recent files [generic]
*	The feature is implemented using MW_RecentFiles class. Basically, it
*	is able to load a previously saved list of files and to show it
*	in designated menu during the MW_RecentFiles::initRecentFiles() call.
*
*	Later, files may be added to the list with
*	MW_RecentFiles::addRecentFile(). As the initialization function binds
*	an internal slot to the menu items representing a recent file,
*	the unit will call MainWindow::_open() whenever the user decides to
*	open one.
*
*	\section ui_templates User interface templates [generic]
*	Class MW_UiTempl exposes a feature of Qt implemented mainly by the
*	<a href="http://doc.qt.nokia.com/latest/qstyle.html">QStyle</a> class.
*	This class "encapsulates the look and feel of a GUI", such as
*	Windows, Mac, Motif. While the implementation in Qt allows for
*	plug-in like use, this implementation using MW_UiTempl does not
*	exposes this to the user. Instead, it will present a list of "templates"
*	that underlying library reports are available.
*
*	The user can choose a menu entry and, as a result, the entire interface
*	is updated, showing choosen templated applied over existing controls.
*	The command line switch \b style is not implemented and wil not work.
*
*	\section style_sheets Style sheets [generic]
*	Style sheets are another implementation of a
*	<a href="http://doc.qt.nokia.com/latest/stylesheet.html">Qt feature</a>
*	that allows the customisation of "the apparence of widgets
*	in addition to what is already possible by subclassing
*	<a href="http://doc.qt.nokia.com/latest/qstyle.html">QStyle</a>
*	(partially exposed in the \ref ui_templates "User interface templates").
*
*	The logical unit that is responsible for style sheet management in
*	MainWindow is the MW_StyleSheets class. It is instantiated in the
*	MainWindow::c_ssheet member.
*
*	Styles sheets are textual specifications that can be set by browsing and
*	loading a file by the user or by choosing a file already present
*	in the plug-ins folder.
*
*	To understand the concepts and implementation of the style sheets,
*	please read <a href="http://doc.qt.nokia.com/latest/stylesheet.html">
*	Qt specification</a>.
*
*	\section basic_mdi Basic MDI [generic]
*	Member MainWindow::c_bs_mdi instantiates the MW_BasicMdi class, providing
*	some common functionality for using Multiple Document Interface in
*	MainWindow.
*
*	The instance will connect itself during the MW_BasicMdi::initBasicMdi
*	to menus ussualy located in \b Window menu, allowing standard
*	arrangements (tile, cascade), navigation (previous, next) and
*	document close (one or all).
*
*	Active MDI document is also tracked and made available to MainWindow,
*	thus allowing certain GUI elements to be enabled only when a document is
*	present. Active document is also evidentiated in the list of opened
*	documents, also hosted usually in \b Window menu.
*
*	MW_BasicMdi::findMdiChild() may be used to find the document that
*	has a particular title.
*
*	\section spec_sheet Sheet slots [specific]
*	This logical unit only manages signals that are intended to reach
*	the active sheet in current MDI document. The slots inside manage
*	either the status of one or more ETSheetView instances (split, remove
*	split, zoom, rotate) or of the sheet that is associated with that MDI
*	document. The functionality of this class shall not overlap
*	with already defined logical units (like \ref basic_slots "Basic slots")
*
*	The current ETSheetView may be splitted horizontally or vertically.
*	Also, current split may be toogled between horizontal and vertical, or
*	it may be deleted altogether. Functionality to remove all splits, leaving
*	a single ETSheetView in MDI document is also provided.
*
*	The relation between current ETSheetView and associated ETSheet may
*	be altered by either zoomin (in or out) or by rotating (clock-wise or
*	counterclock-wise).
*
*/
class MainWindow : public QMainWindow
{
	Q_OBJECT
	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */


	friend class MW_BasicSlots;
	friend class MW_RecentFiles;
	friend class MW_UiTempl;
	friend class MW_StyleSheets;
	friend class MW_BasicMdi;

	friend class MW_SheetSlots;


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */
public:

	/* generic logical units */
	MW_BasicSlots		c_bs_slot;
	MW_RecentFiles		c_r_files;
	MW_UiTempl			c_ui_tpl;
	MW_StyleSheets		c_ssheet;
	MW_BasicMdi			c_bs_mdi;

	/* dedicated logical units */
	MW_SheetSlots		c_sheet;

protected:

	/// GUI components
	Ui::MainWindow *        ui;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor;
	explicit			MainWindow		(QWidget *parent = 0);


	/// destructor;
	~MainWindow		( void );


	/// the pointer to window menu
	QMenu *			menuWin				( void );


	/// number of opened documents at this time
	int				docsOpened			( void );


	/// document having the index doc_idx
	MdiChild *		docByIndex			(int doc_idx);

protected:


	/// actual open function used by recent files and regular open
	bool			_open                   (QString s_file);


	void			closeEvent				(QCloseEvent *event);


	void			createDockWindows		( void );


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//
	/*  INCLUSIONS   ------------------------------------------------------- */


	/*  INCLUSIONS   ======================================================= */
	//
	//
	//
	//

};	/*	class MainWindow	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __MAINWINDOW_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
